package com.aviator.detective.model.variable;

import com.aviator.detective.model.SourceCell;
import com.aviator.detective.model.SourceType;
import com.google.common.base.Preconditions;

import java.io.Serializable;

public class ExpressVariable implements SourceCell,Serializable {
    private String id;
    private String name;
    private String alias;
    private String script;
    private Class variableType;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getScript() {
        return script;
    }

    public void setScript(String script) {
        this.script = script;
    }

    public Class getVariableType() {
        return variableType;
    }

    public void setVariableType(Class variableType) {
        this.variableType = variableType;
    }

    @Override
    public SourceType getType() {
        return SourceType.VARIABLE;
    }

    public String toAviatorScript() {
        Preconditions.checkNotNull(this.script,"variable script not be null");
        return script.trim();
    }
}
